<?php

#--------------------------------------------------
# ALL INCLUDES + STANDARD-VALUES
#--------------------------------------------------
include_once ("include/config.inc");
include_once ("include/template.inc");
include_once ("include/class.db.php5");
include_once ("include/class.tools.php5");
$svo = new db("svoptik");
$tools = new tool();

include_once ("include/global_fix_extern.inc");

#--------------------------------------------------
# CREATE TEMPLATE
#--------------------------------------------------
$t = new Template("templates", "keep");
$t->set_file(array (
	"page" => "svoptik_popup.tpl",
	"link" => "new_link.tpl"
));
#--------------------------------------------------

$t->set_var(array (
	"FORWARD" => ""
));
#--------------------------------------------------
# CREATE CONTENT "GUESTBOOK"
#--------------------------------------------------
global $link_name, $link_text, $link_email, $link_url, $send;

if (empty ($link_url))
	$link_url = "http://www.";
$t->set_var(array (
	"NAME" => $link_name,
	"EMAIL" => $link_email,
	"TEXT" => $link_text,
	"URL" => $link_url,
	"MSG" => ""
));

if (empty ($send))
	$content = $t->parse("", "link", true);
else {
	$content = "
	      <script language=\"javascript\">
	      <!--
	      function win_close() {
	          window.close();
	      }
	      //-->
	      </script>
	      ";
	if (empty ($link_text) || empty ($link_name) || empty ($link_email) || !ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})", $link_email) || $link_url == "http://www.") {
		$t->set_var(array (
			"MSG" => "Bitte &uuml;berpr&uuml;fen Sie Ihre Eingaben!"
		));
		$content .= $t->parse("", "link", true);
	} else {
		$mail_subject = "Anfrage \"neuer Link\" von " . $link_name . " [" . $link_email . "]";
		$mail_name = "webmaster";
		$mail_to = "webmaster@sv-optik.de";

		$mail_text = "
		          Name : " . $link_name . "
		          E-Mail : " . $link_name . "
		          URL : " . $link_url . "
		          Beschreibung : " . $link_text . "
		          ";

		$header = "From:" . $link_name . "<" . $link_email . ">\n";
		$header .= "Reply-To: " . $link_email . "\n";
		$header .= "X-Mailer: PHP/" . phpversion() . "\n";
		$header .= "X-Sender-IP: $REMOTE_ADDR\n";
		$header .= "Content-Type: text/plain";

		if (@ mail($mail_to, $mail_subject, $mail_text, $header))
			$content .= "
					        <p align=\"center\" class=\"text\"><br><br><br>Ihre Anfrage wurde an den<br>" . $mail_name . " [" . $mail_to . "] gesendet.<br><br><a href=\"javascript:win_close();\" class=\"text\">Fenster schlie&szlig;en</a></p>
			              ";
		else
			$content .= "
					        <p align=\"center\" class=\"text\"><br><br><br>Ihre Anfrage konnte nicht an den <br><br>" . $mail_name . " [" . $mail_to . "]<br><br>gesendet werden.<br><br><a href=\"javascript:window.location.replace('new_link.php5?link_name=" . $link_name . "&link_email=" . $link_email . "&link_text=" . $link_text . "&link_url=" . $link_url . "');\" class=\"text\">erneut versuchen</a></p>
					        <p align=\"center\" class=\"text\"><br><a href=\"javascript:win_close()\" class=\"text\">Fenster schlie&szlig;en</a></p>
			              ";
	}
}

#--------------------------------------------------

#--------------------------------------------------
# PARSE & OUTPUT
#--------------------------------------------------
$t->set_var(array (
	"NAVI" => "<img src=\"standard/spacer.gif\" width=\"10\" height=\"20\" border=\"0\" alt=\"\">",
	"sitenav" => "LINKS -> ANMELDEN",
	"content" => $content
));

$t->parse("ALL", "page", true);
$t->p("ALL");
?>
